package com.fit.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.enums.AccountRole;
import com.fit.interfaces.BorrowI;
import com.fit.interfaces.User;
import com.fit.service.BorrowsI;

public class BrowseBorrow {

	@SessionState
	private User user;
	
	private boolean userExists;

	public User getUser() {
		return user;
	}

	Object onActivate(){
		if(!userExists) return Login.class;
		if(user.getRole() == AccountRole.ADMINISTRATOR) return Index.class;
		return null;
	}
	
	@Inject
	@Property
	private BorrowsI borrows;
	
	@Property
	private BorrowI currentBorrow;
	
//	public CarI getFirstCar(){
//		return currentBorrow.getCars().get(0);
//	}
	
	public boolean isUserAdministrator(){
		if(user.getRole() == AccountRole.ADMINISTRATOR) return true;
		return false;
	}
	
	
	
	
}
